VIDEOS
BLOG
PROJECTS
ABOUT
GITHUB
Create a Node Package in es6
Create basic project
$ mkdir example $ cd example $ npm init
Install and config dependencies
$ npm install babel-cli babel-preset-es2015 babel-register babel-core babel-polyfill babel-loader babel-preset-stage-0 --save-dev $ touch .babelrc
add to .babelrc
{ "presets": ["es2015", "stage-0"] }
Create folder structure
$ mkdir src $ mkdir lib $ touch src/index.js
Add to src/index.js
require('babel-polyfill'); export default class Example { this.str = str } excit() {this.str}!` } }
add to package.json
{ "build": "babel src --out-dir lib", "prepublish": "npm run build" } }
$ npm run build
Test
## create new project $ mkdir test_example $ cd test_example $ npm init $ npm install ../example $ touch index.js
add to index.js
var ex = require(‘example’); console.log(new ex(‘hello’).excit())
setup git
$ git init $ git add . $ commit -m "init example" $ touch .gitignore $ touch .npmignore
add to .gitignore
.DS_STORE node_modules build/ .module-cache *.log* lib
add to .npmignore
node_modules src
Sign up for git up at github.com
Create example repo
$ git remote add origin git@github.com:kevinponce/example.git
Check if it add remote origin
$ git remote -v
setup npm for project
$ npm adduser $ npm publish
If that fails, change project name package.json to be like "name": "@your_username/example"
Voila
{tag}